void set_interval(void)
{
	int hrs=0, min=0, flag=1, total_min=0;		// defining variables (to be done globally in main programme)

	while(1)							// Infinite while loop till break
	{	
		ON_JOYSTICK_LEFT			// Shifting to hrs variable
		{
			WAIT_FOR_RELEASE_JOYSTICK_LEFT
			flag=1;
		}
		ON_JOYSTICK_RIGHT			// Shifting to min variable
		{
			WAIT_FOR_RELEASE_JOYSTICK_RIGHT
			flag=2;
		}
		
		if(flag==1)
		{
			ON_JOYSTICK_UP			// increasing hrs variable till max 24
			{
				WAIT_FOR_RELEASE_JOYSTICK_UP
				hrs++;
	
				if(hrs==25)
				{
					hrs=0;
				}
			}
	
			ON_JOYSTICK_DOWN		// decreasing hrs variable till minimum 0
			{
				WAIT_FOR_RELEASE_JOYSTICK_DOWN
				hrs--;

				if(hrs==-1)
				{
					hrs=24;
				}
			}

			LCD_TEXT("hrs=")
			LCD_NUMBER(hrs)
			WAIT_SEC(0.1)
		}

		if(flag==2)
		{
			ON_JOYSTICK_UP			// increasing min variable till max 55
			{
				WAIT_FOR_RELEASE_JOYSTICK_UP
				min = min + 5;

				if(min==60)
				{
					min = 0;
				}
			}

			ON_JOYSTICK_DOWN		// decreasing min variable till minimum 0
			{
				WAIT_FOR_RELEASE_JOYSTICK_DOWN
				min = min - 5;

				if(min==-5)
				{
					min=55;
				}
			}

			LCD_TEXT("min=")
			LCD_NUMBER(min)
			WAIT_SEC(0.1)
		}

		ON_JOYSTICK_CENTER			// break while loop when joystick center is pressed
		{
			WAIT_FOR_RELEASE_JOYSTICK_CENTER
			if(hrs==0 & min==0)
			{
				LCD_TEXT("Enter Valid Time")
				WAIT_SEC(0.5)
			}
			else
			{
			break;
			}
		}
	}

	total_min = min + (hrs * 60);	//total time in minutes if required 
									//(optional depending on convenience) 
									// can be returned if necessary

	return 0;
}